'use strict'
const _ = require('lodash')
const moment = require('moment')
const Env = use('Env')
const { ExhibitorReceipt } = require("../../../Models");
class ReceiptController {
  async index({ request, response, params }) {
    let query = ExhibitorReceipt.query()
    let {
      page = 1,
      pageSize = 10,
      exhibitorName,
      phone,
    } = request.get()
    if(exhibitorName){
      exhibitorName = decodeURI(exhibitorName.trim())
      if (exhibitorName) query.whereRaw(`exhibitorName like ?`,`%${exhibitorName}%`)
    }
    if(phone){
      phone = decodeURI(phone.trim())
      if (phone) query.whereRaw(`phone like ?`,`${phone}`)
    }
    const receipts = await query.paginate(page, pageSize)
    response.json({ error: 0, data: receipts })

  }
}
module.exports = ReceiptController